<?php
namespace app\api\controller;


use app\extra\DBCont;
use think\Db;

/**
 * @title 进行投票
 * @description 接口说明
 * @group 移动端投票
 * @header name:authorization require:1 default: desc:登陆的token
 */
class VotePlayer extends Base
{
    /**
     * @title 进行投票
     * @description 用户登录
     * @author hardy
     * @url /admin/VotePlayer
     * @method POST
     * @param name:player_id type:整形或数组 require:1 default: other: desc:选手id
     *
     */
    public function create(){
        $id = input('post.player_id');
        if (empty($id)){
            $this->responseFail('请选择选手');
        }
        if (!is_array($id)){
            $id = [$id];
        }
        $user = getPersonId();
        $model = model('VotePlayer');
        $r = $model->vote($id, $user);
        if ($r === false){
            $this->responseFail($model->getError());
        }
        $this->responseSuccess();
    }
}